package com.ambition.demo.kafka.controller;


import com.ambition.demo.dto.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/kafka")
public class KafkaSendController {

    @Autowired
    KafkaTemplate kafkaTemplate;


    @PostMapping("send")
    public Result kafkaSend(@RequestParam String str){
        kafkaTemplate.send("clj_test",str);
        kafkaTemplate.flush();
        return Result.ok();
    }
}
